package org.anddev.andengine.extension.svg.node;
/**
 * @author Eric Depta
 * @since 01:14:00 - 28.02.2011
 */
import java.util.ArrayList;
import java.util.List;

import org.anddev.andengine.extension.svg.SVGDoc;
import org.anddev.andengine.extension.svg.SVGPath;
import org.anddev.andengine.extension.svg.util.math.Ellipse;
import org.anddev.andengine.extension.svg.util.transform.TransformDoc;
import org.anddev.andengine.util.SAXUtils;
import org.xml.sax.Attributes;

import com.badlogic.gdx.math.Vector2;

public class EllipseNode extends PathNode {
	public EllipseNode(final SVGDoc pSVGDoc){
		super(pSVGDoc);
	}
	
	public void create(final Attributes pAttributes, final TransformDoc pTransform){
		super.create(pAttributes, pTransform);
	}
	
	@Override
	protected void createPath(final Attributes pAttributes){
		final List<Vector2> veclist = new ArrayList<Vector2>();
		final int segments = SAXUtils.getIntAttribute(pAttributes, TAG_ATTRIBUTE_CURVE_SEGMENTS, 4);
		Ellipse.ellipse(
			veclist, 
			segments, 
			new Vector2(
				SAXUtils.getFloatAttribute(pAttributes, TAG_ATTRIBUTE_CENTER_X, 0),
				SAXUtils.getFloatAttribute(pAttributes, TAG_ATTRIBUTE_CENTER_Y, 0)
			), 
			SAXUtils.getFloatAttribute(pAttributes, TAG_ATTRIBUTE_RADIUS_X, 0), 
			SAXUtils.getFloatAttribute(pAttributes, TAG_ATTRIBUTE_RADIUS_Y, 0), 
			0, 
			0, 
			360
		);
		this.svgPath = new SVGPath(
			veclist,
			true
		);
	}
}
